< previous page page_127 next page >

Page 127
The UserControl
The PrivateCtl control is a trivial control that draws 16 vertical color bars, each in a different color.
' OleDraw Sample
' Copyright © 1998 by Desaware Inc. All Rights Reserved
Option Explicit

Private Sub UserControl_Paint()
   Dim x As Long
   Dim bandsize As Long
bandsize = ScaleWidth / 16
   For x = 0 To 15
      Line (bandsize * x, 0)-(bandsize * (x + 1), ScaleHeight), _
      QBColor(x Mod 16), BF
   Next x
End Sub
The Form
The OleDraw function is declared as follows. The RECT structure contains four fields corresponding to the left, top, right, and bottom of the rectangle in which to draw. The aspects array contains the values 1, 2, 4, and 8, corresponding to the four possible Aspect values. As mentioned earlier, the only value that will not result in an error for most ActiveX controls is the number 1.
' OLE Drawing Puzzle
' Copyright © 1998 by Desaware Inc. All Rights Reserved
Option Explicit

Private Declare Function OleDraw Lib "ole32.dll" _
   (pUnk As Object, _
   ByVal dwAspect As Long , _
      ByVal hdcDraw As Long, _
      lprcBounds As RECT) As Long

Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long

 
< previous page page_127 next page >